package org.bukkit.pm.afk;

import org.bukkit.entity.Player;

/**
 * Track afk status for players (online only)
 * @author Matteo
 *
 */
public class AfkPlayer {

	private Player _player;
	private long _time;
	private String _reason;
	
	public AfkPlayer(Player p, long t, String reason){
		_player = p;
		_time = t;
		_reason = reason;
	}
	
	public String getName(){
		return _player.getName();
	}
	
	public String getReason(){
		return _reason;
	}
	
	public long getTime(){
		return _time;
	}
	
	public Player getPlayer(){
		return _player;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer(_player.getName());
		long dt = (System.currentTimeMillis()-_time)/60000; //get minutes
		sb.append(" ");
		sb.append(Long.toString(dt));
		sb.append(" minutes ago");
		if(_reason!=null){
			sb.append(" (");
			sb.append(_reason);
			sb.append(")");
		}
		return sb.toString();
	}
}
